# -*-coding: utf-8 -*-
"""
    @Theme   : 
    @Time    : 2024/7/16 9:54
    @Author  : YamFish
    @Url     : https://www.zhihu.com/people/yamfish
"""
from .mongo_util import MongoUtil
from .redis_util import RedisUtil, BloomFilter
from qanda.models.mongo_client import MongoClient
from qanda.models.redis_client import RedisClient


class DBUtils:
    def __init__(self, app=None):
        self.mongo = None
        self.redis = None
        self.bloom = None
        if app:
            self.init(app)

    def init(self, app):
        mongo_db = MongoClient(app)
        redis_db = RedisClient(app)
        self.mongo = MongoUtil(app, mongo_db)
        self.redis = RedisUtil(app, redis_db)
        self.bloom = BloomFilter(app, self.redis)


db_utils = DBUtils()
